package com.cleaningcloud.cld.controller;

import java.util.List;

import com.cleaningcloud.cld.domain.dto.CldTrainIecturerDto;
import com.cleaningcloud.cld.domain.dto.CldTrainReceiveDto;
import com.cleaningcloud.cld.domain.vo.CldTrainIecturerVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldTrainIecturer;
import com.cleaningcloud.cld.service.ICldTrainIecturerService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 培训讲师Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-22
 */
@RestController
@RequestMapping("/iecturer")
public class CldTrainIecturerController extends BaseController
{
    @Autowired
    private ICldTrainIecturerService cldTrainIecturerService;

    /**
     * 查询培训讲师列表
     */
    @RequiresPermissions("cld:iecturer:list")
    @GetMapping("/list")
    public TableDataInfo list(CldTrainIecturerDto cldTrainIecturer)
    {
        startPage();
        List<CldTrainIecturerVo> list = cldTrainIecturerService.selectCldTrainIecturerList(cldTrainIecturer);
        return getDataTable(list);
    }


    /**
     * 获取培训讲师详细信息
     */
    @RequiresPermissions("cld:iecturer:query")
    @GetMapping(value = "/getTrainIecturerStaffListInfo")
    public AjaxResult getTrainIecturerStaffListInfo(CldTrainReceiveDto cldTrainReceiveDto)
    {
        return success(cldTrainIecturerService.getTrainIecturerStaffListInfo(cldTrainReceiveDto));
    }

    /**
     * 新增培训讲师
     */
    @RequiresPermissions("cld:iecturer:add")
    @Log(title = "培训讲师", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldTrainIecturer cldTrainIecturer)
    {
        return toAjax(cldTrainIecturerService.insertCldTrainIecturer(cldTrainIecturer));
    }

    /**
     * 修改培训讲师
     */
    @RequiresPermissions("cld:iecturer:edit")
    @Log(title = "培训讲师", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldTrainIecturer cldTrainIecturer)
    {
        return toAjax(cldTrainIecturerService.updateCldTrainIecturer(cldTrainIecturer));
    }

    /**
     * 删除培训讲师
     */
    @RequiresPermissions("cld:iecturer:remove")
    @Log(title = "培训讲师", businessType = BusinessType.DELETE)
	@DeleteMapping("/{trainIecturerIds}")
    public AjaxResult remove(@PathVariable Long[] trainIecturerIds)
    {
        return toAjax(cldTrainIecturerService.deleteCldTrainIecturerByTrainIecturerIds(trainIecturerIds));
    }


    /**
     * 取消任职培训师
     */
    @RequiresPermissions("cld:iecturer:remove")
    @Log(title = "培训讲师", businessType = BusinessType.DELETE)
    @DeleteMapping("/delCancePosition/{trainIecturerId}")
    public AjaxResult delCancePosition(@PathVariable Long trainIecturerId)
    {
        return toAjax(cldTrainIecturerService.delCancePosition(trainIecturerId));
    }
}
